﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _09_1对多.乐观并发
{
    public class HoursConfig : IEntityTypeConfiguration<Hours>
    {
        void IEntityTypeConfiguration<Hours>.Configure(EntityTypeBuilder<Hours> builder)
        {
            builder.ToTable("T_Hours");
            builder.Property(e=>e.Name).HasMaxLength(50);

            // 乐观锁  并发令牌  适合单个并发
            // builder.Property(e => e.Owen).IsConcurrencyToken();
            
            // 多个字段 并发 要新增一个列 并发令牌(推荐这个，可以适合单个属性和多个属性)
            builder.Property(e => e.RowVersion).IsRowVersion();
        }
    }
}
